package com.itlong.cloud.commons.service.impl;

import com.itlong.cloud.POJO.PO.SysCodePO;
import com.itlong.cloud.commons.dao.IDataDictionaryDao;
import com.itlong.cloud.commons.service.IDataDictionaryService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * <desc>
 *      数据字典接处理接口实现类
 * </desc>
 *
 * @createDate 2017/10/18
 */
@Service
public class DataDictionaryServiceImpl implements IDataDictionaryService{

    @Autowired
    IDataDictionaryDao iDataDictionaryDao;

    /**
     * <desc>
     *      根据类型获取数据字典数据
     * </desc>
     *
     * @param codeType 类型
     * @return List<SysCodePO> 数据字典实体类集
     * @author zhangs
     * @createDate 2017/10/18
     */
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<SysCodePO> get(String codeType) throws Exception {
        List<SysCodePO> sysCodePOS = new ArrayList<>();
        if(StringUtils.isBlank(codeType)) {
            return sysCodePOS;
        }
        sysCodePOS = iDataDictionaryDao.getByCodeType(codeType);
        return sysCodePOS;
    }
}
